package viewControl;

import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.MouseTrackListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Label;

public class StartListener implements MouseListener , MouseTrackListener{

    
    private Image startL;
    private Image startDR;
    private Image startDS;
    private Image exitL;
    private Image exitDS;
    
    public StartListener() {
	startL = new Image(null , getClass().getResourceAsStream("startL.png"));
	startDR = new Image(null , getClass().getResourceAsStream("startDR.png"));
	startDS = new Image(null , getClass().getResourceAsStream("startDS.png"));
	exitL = new Image(null , getClass().getResourceAsStream("exitL.png"));
	exitDS = new Image(null , getClass().getResourceAsStream("exitDS.png"));
	
    }

    public void mouseDoubleClick(MouseEvent arg0) {
    }

    public void mouseDown(MouseEvent e) {
	
	if(((Label)e.widget).getData().equals("start")){
	    ((Label)e.widget).setImage(startDS);
	}
	else if(((Label)e.widget).getData().equals("exit")){
	    ((Label)e.widget).setImage(exitDS);
	    System.exit(0);
	}
//    	int size =Manager.getInstance().getWorkArray(View.getInstance().getSelectArrayIndex()).length;
//    	Integer[] worArray = new Integer[size];
//    	for(int i=0 ;i< size ;i++){
//    		worArray[i]=((Integer)Manager.getInstance().getWorkArray(View.getInstance().getSelectArrayIndex())[View.getInstance().getSelectArrayIndex()]);
//    	}
//    	Painter.getInstance().setWorkArray(worArray);
//    	SortManager.getInstance().manageSort
//    	(Manager.getInstance().getWorkArray(View.getInstance().getSelectArrayIndex()), 
//    			View.getInstance().getSimulationArray());
    }
    public void mouseUp(MouseEvent e) {
	if(((Label)e.widget).getData().equals("start")){
	    ((Label)e.widget).setImage(startDR);
	}
	else if(((Label)e.widget).getData().equals("exit")){
	    ((Label)e.widget).setImage(exitDS);
	}
    }

    public void mouseEnter(MouseEvent e) {
	if(((Label)e.widget).getData().equals("start")){
	    ((Label)e.widget).setImage(startDR);
	}
	else if(((Label)e.widget).getData().equals("exit")){
	    ((Label)e.widget).setImage(exitDS);
	}
    }

    public void mouseExit(MouseEvent e) {
	if(((Label)e.widget).getData().equals("start")){
	    ((Label)e.widget).setImage(startL);
	}
	else if(((Label)e.widget).getData().equals("exit")){
	    ((Label)e.widget).setImage(exitL);
	}
    }

    public void mouseHover(MouseEvent arg0) {
    }

}
